/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package redclient.Items;

import java.io.Serializable;

/**
 *
 * @author Isaias
 */
public class CustomField implements Serializable {
    
    private String name;

    private String id;

    private CustomFieldFormat format;
    
    private int minLength;
    
    private int maxLength;
    
    private String regularExpresion;
    
    private String defaultValue;

    private String value;

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
    
    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the format
     */
    public CustomFieldFormat getFormat() {
        return format;
    }

    /**
     * @param format the format to set
     */
    public void setFormat(CustomFieldFormat format) {
        this.format = format;
    }

    /**
     * @return the minLength
     */
    public int getMinLength() {
        return minLength;
    }

    /**
     * @param minLength the minLength to set
     */
    public void setMinLength(int minLength) {
        this.minLength = minLength;
    }

    /**
     * @return the maxLength
     */
    public int getMaxLength() {
        return maxLength;
    }

    /**
     * @param maxLength the maxLength to set
     */
    public void setMaxLength(int maxLength) {
        this.maxLength = maxLength;
    }

    /**
     * @return the regularExpresion
     */
    public String getRegularExpresion() {
        return regularExpresion;
    }

    /**
     * @param regularExpresion the regularExpresion to set
     */
    public void setRegularExpresion(String regularExpresion) {
        this.regularExpresion = regularExpresion;
    }

    /**
     * @return the defaultValue
     */
    public String getDefaultValue() {
        return defaultValue;
    }

    /**
     * @param defaultValue the defaultValue to set
     */
    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    @Override
    public String toString() {
        return String.format("%s[%s]=%s", this.name, this.id, this.value);
    }

    @Override
    public boolean equals(Object obj) {
        boolean result = false;
        if( obj != null && obj instanceof CustomField )
        {
            CustomField cf = (CustomField)obj;
            result = cf.name.equals(name) && cf.id.equals("id");
        }
        return result;
    }

    @Override
    public int hashCode() {
        return name.length();
    }
}
